package hello.word.m2.maven.controller;

import hello.word.m2.maven.dao.BookDao;
import hello.word.m2.maven.dao.BookRepository;
import hello.word.m2.maven.support.AutoSqlObject;
import io.micronaut.context.BeanContext;
import io.micronaut.http.MediaType;
import io.micronaut.http.annotation.Controller;
import io.micronaut.http.annotation.Get;
//import lombok.extern.log4j.Log4j2;
import org.jdbi.v3.core.Jdbi;

import javax.inject.Inject;

@Controller("/hello")
//@Log4j2
public class HelloController {

//    BookDao bookDao;

    BookRepository bookRepository;

    /*Jdbi jdbi;*/

   /* @Inject
    public HelloController(BookDao bookDao) {
        this.bookDao = bookDao;
    }*/

    public HelloController(BookRepository bookRepository) {
        this.bookRepository = bookRepository;
    }

    /*@Inject
    public HelloController(Jdbi jdbi) {
        this.jdbi = jdbi;
    }*/

    @Get(produces = MediaType.TEXT_PLAIN)
    public String index() {
//        log.info("index");
//        AutoSqlObject sqlObject= jdbi.getConfig(AutoSqlObject.class);
//        Object object= jdbi.getConfig(AutoSqlObject.class).getObject(BookDao.class.getName());
//        log.info("{}",object);
//        bookRepository.findById(10l);
        bookRepository.selectAll();
        return "Hello World";
    }
}
